<div class="bjui-pageContent">
    <div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
        <form data-toggle="ajaxsearch" data-options="{searchDatagrid:$.CurrentNavtab.find('#process-lists-table')}">
            <fieldset>
                <legend style="font-weight:normal;">搜索：</legend>
                <div style="margin:0; padding:1px 5px 5px;">

                    <span>名称：</span>
                    <input type="text" name="title" class="form-control" size="30">

                    <span>类型：</span>
                    <select name="type" data-toggle="selectpicker">
                        @foreach ($typeList as $val)
                            <option value="{{$val['id']}}">{{$val['title']}}</option>
                        @endforeach
                    </select>

                    <div class="btn-group">
                        <button type="submit" class="btn-green" data-icon="search">开始搜索</button>
                        <button type="reset" class="btn-orange" data-icon="times">重置</button>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <table class="table table-bordered" id="process-lists-table" data-toggle="datagrid" data-options="{
        tableWidth: '100%',
        height: '90%',
        gridTitle : '工序列表',
        showToolbar: true,
        toolbarItem: 'add,del,export',
        local: 'local',
        dataUrl: '/admin/process/list',
        paging: {pageSize:100, pageCurrent:1},
        linenumberAll: false,
        showLinenumber: false,
        showCheckboxcol: true,
        filterThead: false,
        showEditbtnscol: '操作',
        editUrl: '/admin/process/edit',
        editCallback:editCallback,
        delUrl:'/admin/process/delete',
        delPK:'id',
        delConfirm: true,
        exportOption:{type:'file', options:{url:'admin/export/process',type:'post',data: {_token : '{{ csrf_token() }}'}}}
    }">
        <thead>
        <tr>
            <th data-options="{name:'id',width:50,align:'center',add:false,edit:false}">编号</th>
            <th data-options="{name:'title',align:'center'}">工序名称</th>
            <th data-options="{name:'measurement_unit',align:'center'}">计量单位</th>
            <th data-options="{name:'is_sum',type:'select',items:[{0:'不累加'},{1:'累加'}],align:'center'}">数量是否累加</th>
            <th data-options="{name:'is_hide_moneydata',type:'select',items:[{1:'不隐藏'},{0:'隐藏'}],align:'center'}">是否隐藏金额相关数据</th>
            <th data-options="{name:'is_same_unit',type:'select',items:[{1:'一致'},{0:'不一致'}],align:'center'}">单位是否和成品一致</th>
            <th data-options="{name:'type',type:'select',items:{{$typeListJson}},align:'center'}">工序类型</th>
            <!--<th data-options="{name:'is_last',items:[{0:'不确定'},{1:'字段'},{2:'工序'}],add:false,edit:false,align:'center'}">关联</th>-->
            <!--<th data-options="{align:'center',render:action_manage}">动作管理</th>-->
            <th data-options="{align:'center',render:field_manage}">关联管理</th>
        </tr>
        </thead>
    </table>
</div>
<script type="text/javascript">

    function action_manage(value, data)
    {
        var html      = '<button type="button" class="btn btn-info" data-toggle="navtab" data-options="';
            html      += '{id:\'process-permission-list-navtab\',title:\''+data.title+'动作管理\',fresh:true,';
            html      += 'url:\'/admin/process/permission-list\',data:{id:' + data.id + '}}';
            html      += '">查看</button>';
        return html
    }
    function field_manage(value, data)
    {
        var field_html      = '<button type="button" class="btn btn-info" data-toggle="dialog" data-options="';
        field_html      += '{id:\'process-field-edit-dialog\',title:\''+data.title+'-字段分配\',';
        field_html      += 'fresh:true,width:750,height:500,';
        field_html      += 'url:\'/admin/process/field-edit\',data:{id:' + data.id + '}}';
        field_html      += '"> 字段分配</button>';
        var field_set_html  = '<button type="button" class="btn btn-info" data-toggle="navtab" data-options="';
        field_set_html  += '{id:\'process-field-manage-navtab\',title:\''+data.title+'-字段管理\',fresh:true,';
        field_set_html  += 'url:\'/admin/process/field-manage\',data:{id:' + data.id + '}}';
        field_set_html  += '"> 字段管理</button>';
        var process_html    = '<button type="button" class="btn btn-info" data-toggle="navtab" data-options="';
        process_html    += '{id:\'process-process-edit-navtab\',title:\'工序分配\',fresh:true,';
        process_html    += 'url:\'/admin/process/process-edit\',data:{id:' + data.id + '}}';
        process_html    += '"> 工序分配</button>';
        var copy_html      = '<button type="button" class="btn btn-info" data-toggle="dialog" data-options="';
        copy_html      += '{id:\'ygt-bjui-dialog\',title:\''+data.title+'-复制\',';
        copy_html      += 'fresh:true,width:450,height:300,';
        copy_html      += 'url:\'/admin/process/copy\',data:{id:' + data.id + '}}';
        copy_html      += '"> 复制工序</button>';
        var html            = '';
        var is_last         = data.is_last;
        if( is_last == 1 ){
            html            = field_html + field_set_html;
        } else if( is_last == 2 ){
            //html            = process_html;
        } else {
            //html            = field_html + process_html;
            html            = field_html;
        }
        html            += copy_html;
        return html
    }
</script>